using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.UI;

namespace Utils.MaterialProperty.UGUI
{
    [System.Serializable]
    public class MaterialPropertyUniData
    {
        [HideInInspector] public string propertyDisplayName;
        [HideInInspector] public MaterialPropertyType propertyType;
        [HideInInspector] [ShowIf("IsVector")] public VectorType vectorType;
        [HideInInspector] public float min;
        [HideInInspector] public float max;
        [ShowIf("IsFloat")] [PropertyRange("min","max")] [LabelText("@propertyDisplayName")]public float floatValue;
        [ShowIf("IsInteger")] [PropertyRange("min","max")][LabelText("@propertyDisplayName")]public int intValue;
        [ShowIf("IsVector2")] [LabelText("@propertyDisplayName + \"-x\"")]public float x;
        [ShowIf("IsVector2")] [LabelText("@propertyDisplayName + \"-y\"")]public float y;
        [ShowIf("IsVector3")] [LabelText("@propertyDisplayName + \"-z\"")]public float z;
        [ShowIf("IsVector4")] [LabelText("@propertyDisplayName + \"-w\"")]public float w;
        [ShowIf("IsColor")][LabelText("@propertyDisplayName")] public Color color = Color.white;
        [ShowIf("IsMatrix")][LabelText("@propertyDisplayName")] public Matrix4x4 matrix;
        [ShowIf("IsTexture")][LabelText("@propertyDisplayName")] public Texture texture;
        
        protected bool IsFloat => propertyType == MaterialPropertyType.Float;
        protected bool IsInteger => propertyType == MaterialPropertyType.Int;
        protected bool IsVector => propertyType == MaterialPropertyType.Vector;
        protected bool IsMatrix => propertyType == MaterialPropertyType.Matrix;
        protected bool IsTexture => propertyType == MaterialPropertyType.Texture;
        protected bool IsConstantBuffer => propertyType == MaterialPropertyType.ConstantBuffer;
        protected bool IsComputeBuffer => propertyType == MaterialPropertyType.ComputeBuffer;
        protected bool IsVector2 => ((int)vectorType & (int)VectorType.Vector2) == (int)VectorType.Vector2;
        protected bool IsVector3 => ((int)vectorType & (int)VectorType.Vector3) == (int)VectorType.Vector3;
        protected bool IsVector4 => ((int)vectorType & (int)VectorType.Vector4) == (int)VectorType.Vector4;
        protected bool IsColor => ((int)vectorType & (int)VectorType.Color) == (int)VectorType.Color;
    }
}
